﻿//移动地服2.0测试地址   杜良焰
var  yddfProUrl = "http://mpservice.ceair.com/mpservice/";



//接口地址
//var pubUrl = "http://mt.ceair.com:7001/HccMobile/rest/HccMobile/query";
//var loginUrl="http://mt.ceair.com:7001/HccMobile/rest/HccMobile/login";
//var insertUrl="http://mt.ceair.com:7001/HccMobile/rest/HccMobile/insert";

//正式环境
//var pubUrl = "http://mphcc.ceair.com:80/HccMobile/rest/HccMobile/query";
//var loginUrl = "http://mphcc.ceair.com:80/HccMobile/rest/HccMobile/login";
//var insertUrl="http://mphcc.ceair.com:80/HccMobile/rest/HccMobile/insert";

//
//var pubUrl = "http://mphcc.ceair.com:80/HccMobileTest/rest/HccMobile/query";
//var loginUrl = "http://mphcc.ceair.com:80/HccMobileTest/rest/HccMobile/login";
//var insertUrl="http://mphcc.ceair.com:80/HccMobileTest/rest/HccMobile/insert";

//var pubUrl = "http://172.28.22.37:80/HccMobileTest/rest/HccMobile/query";
//var loginUrl = "http://172.28.22.37:80/HccMobileTest/rest/HccMobile/login";
//var insertUrl="http://172.28.22.37:80/HccMobileTest/rest/HccMobile/insert";

//测试服务器地址
var pubUrl = "http://flymt.ceair.com:80/HccMobile/rest/HccMobile/query";
var loginUrl = "http://flymt.ceair.com:80/HccMobile/rest/HccMobile/login";
var insertUrl = "http://flymt.ceair.com:80/HccMobile/rest/HccMobile/insert";
					
//var pubUrl = "http://mgstest.ceair.com:8080/HccMobile/rest/HccMobile/query";
//var loginUrl = "http://mgstest.ceair.com:8080/HccMobile/rest/HccMobile/login";
//var insertUrl = "http://mgstest.ceair.com:8080/HccMobile/rest/HccMobile/insert";

//熊昂
//var loginUrl="http://172.20.52.155:8080/HccMobile/rest/HccMobile/login";
//var pubUrl="http://172.20.52.155:8080/HccMobile/rest/HccMobile/query";
//var insertUrl = "http://172.20.52.155:8080/HccMobile/rest/HccMobile/insert";


//var loginUrl="http://crewbook.ceair.com:8080/HccMobileTest/rest/HccMobile/login";
//var pubUrl="http://crewbook.ceair.com:8080/HccMobileTest/rest/HccMobile/query";
//var insertUrl = "http://crewbook.ceair.com:8080/HccMobileTest/rest/HccMobile/insert";

//var loginUrl="http://192.168.1.125:8080/HccMobileTest/rest/HccMobile/login";
//var pubUrl="http://192.168.1.125:8080/HccMobileTest/rest/HccMobile/query";
//var insertUrl = "http://192.168.1.125:8080/HccMobileTest/rest/HccMobile/insert";

//var loginUrl="http://192.168.0.121:8080/HccMobileTest/rest/HccMobile/login";
//var pubUrl="http://192.168.0.121:8080/HccMobileTest/rest/HccMobile/query";
//var insertUrl = "http://192.168.0.121:8080/HccMobileTest/rest/HccMobile/insert";

//var loginUrl="http://192.168.0.104:8080/HccMobileTest/rest/HccMobile/login";
//var pubUrl="http://192.168.0.104:8080/HccMobileTest/rest/HccMobile/query";
//var insertUrl = "http://192.168.0.104:8080/HccMobileTest/rest/HccMobile/insert";

//var loginUrl="http://192.168.0.117:8080/HccMobileTest/rest/HccMobile/login";
//var pubUrl="http://192.168.0.117:8080/HccMobileTest/rest/HccMobile/query";
//var insertUrl = "http:192.168.0.117:8080/HccMobileTest/rest/HccMobile/insert";


//震动、响铃开关，1为开启；0为关闭
var IFVibration = "1";
var IFRing = "1";
//“开始”、“结束”、“返回”3个圆圈按钮二次确认，1为开启；0为关闭
var clickConfirmation = "1";
//是否默认展开"授受"、"出发"、"到位"、"返回"按钮面板，1为打开；0为关闭
var unfoldBtns = "1";

var loginInterfaceError='登录失败，请稍后重试';
var interfaceError1 = '数据信息获取失败，请重试';
var interfaceError2 = '您的账号在另一地点登录，请重新登录';
var interfaceError3 = '请确认帐号密码是否正确';
var interfaceError4 = '已经在另一地点登录，是否强制登录';
var interfaceError5 = '服务器没有响应，请稍后重试';
var interfaceError6 = '资源重复，是否强制登录';
var interfaceError7 = '网络异常，请稍后重试';
var interfaceError9 = '资源能力变更，请重新登录';

var sktCall='index';

var isSML = (window.navigator.platform == 'Win32') ? 1 : 0; /*是否在模拟器上运行, 1是0否*/
var android = window.navigator.userAgent.indexOf('Android'); /*是否在Android系统上运行, (android>=0)是*/
String.prototype.format = function (args) {
    var result = this;
    if (arguments.length > 0) {
        if (arguments.length == 1 && typeof (args) == "object") {
            for (var key in args) {
                var reg = new RegExp("({" + key + "})", "g");
                if (args[key] != undefined)
                    result = result.replace(reg, args[key]);
                else
                    result = result.replace(reg, '');
            }
        }
        else {
            for (var i = 0; i < arguments.length; i++) {
                var reg = new RegExp("({)" + i + "(})", "g");
                if (arguments[i] != undefined)
                    result = result.replace(reg, arguments[i]);
                else
                    result = result.replace(reg, '');
            }
        }
    }
    return result;
}

//打开新窗口
function open_new(name, url, anim) {
    uexWindow.open(name, '0', url, anim, '', '', '0');
}

/*打开新窗口
* @winName: 窗口id
* @url: 本地页面url
* @anim: 窗口动画id
*/
function openwin(winName, url, anim) {

    uexWindow.open(winName, "0", (url ? url : (winName + '.html')), (anim ? anim : 10), "", "", "4", "275");
}

//关闭窗口
function winClose(n) {
    uexWindow.close(n);
}

/*浮动窗口执行JS脚本*/
function ueppscript(wn, pn, scr) {
    uexWindow.evaluatePopoverScript(wn, pn, scr);
}
function uescript(wn, scr){
	uexWindow.evaluateScript(wn,'0',scr);
}

/*判断是否不为空*/
function isDefine(para) {
    if (typeof para == 'undefined' || para == "" || para == null || para == undefined)
        return false;
    else
        return true;
}

//错误处理
function getJSONError(err) {
    if (err.message == 'network error!') {
		loadingStart( '请检查网络状态', '3000');
//		writeTxt('前台：' + 请检查网络状态);
	}
	else if (err.message == 'json parse failed!') {
		loadingStart('数据解析错误', '3000');
//		writeTxt('前台：' + 数据解析错误);
	}
	else if (err.message == 'file does not exist!') {
		loadingStart( '文件不存在', '3000');
//		writeTxt('前台：' + 文件不存在);
	}
	else if (err.message == 'read file failed!') {
		loadingStart('文件读取错误', '3000');
//		writeTxt('前台：' + 文件读取错误);
	}
	else {
		loadingStart( '发现未知错误', '3000');
//		writeTxt('前台：' + 发现未知错误);
	}
}

function toast(type,word,time)
{
    uexWindow.toast('0', '5', word, time);
}

function closeToast() {
    uexWindow.closeToast();
}

//获取元素 
function $$(id) {
    return document.getElementById(id);
}

function logs(s) {
    uexLog.sendLog(s);
}

function setHtml(id, html) {
    if ("string" == typeof (id)) {
        var ele = $$(id);
        if (ele != null) {
            ele.innerHTML = html == null ? "" : html;
        }
    }
    else
        if (id != null) {
            id.innerHTML = html == null ? "" : html;
        }
}

//本地存储
var lcstor = window.localStorage;
function setStorage(key, value) {
    if (lcstor)
        lcstor[key] = value;
    //else 
    //alert('localStorage error');
}

function getStorage(key) {
    if (lcstor) {
        for (i in lcstor) {
            if (i == key)
                return lcstor[i];
        }
    }
    //else 
    //alert('localStorage error');
}

function clearStorage(key) {
    if (lcstor) {
        if (key)
            lcstor.removeItem(key);
        else
            lcstor.clear();
    }
    //else 
    //alert('localStorage error');
}

function getData_lzz(url, data, callback) {
    $.ajax({
        type: "POST",
        url: url,
        dataType: "JSON",
        contentType: "application/json; charset=utf-8",
        data: data,
        cache: false,
        timeout: 60000,
        success: function (json) {
            callback(json);
        },
        error: function (error) {
            uexWindow.toast('0', '5', interfaceError7, 1000);
        }
    });
}

var loading;
function loadingStart(word, time) {
    uexWindow.toast('0', '5', word, time);
	var a = document.body.scrollHeight;
    $$("diyLoadDiv").outerHTML = '<div id="diyLoadDiv" class="um-vp up2 c-bla " style="opacity:0.5; height:'+ a +'px"></div>';

    if (isDefine(time) && time != 0) {
        loading = setInterval(diyCloseLoading, time);
    }
}

function loadingEnd() {
    uexWindow.closeToast();
    //关闭loading
    $$("diyLoadDiv").className = "uhide";
}

//关闭DIVloading---YHN
function diyCloseLoading() {
    clearInterval(loading);
    $$("diyLoadDiv").className = "uhide";
}
function createDoc(text) {
    var xmlDoc = null;
    try {
        parser = new DOMParser();
        xmlDoc = parser.parseFromString(text, "text/xml")
    }
    catch (e) {
        try {
            xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
            xmlDoc.async = "false";
            xmlDoc.loadXML(text)
        }
        catch (e) {
        }
    }
    return xmlDoc
}

function getNodeValue(xmlObject, nodeName, index) {
    try {
        var target = xmlObject.getElementsByTagName(nodeName)[index].firstChild.data
    }
    catch (e) {
        var target = ""
    }
    return target
}

function call(num) {
    uexCall.call(num);
}

function sms(num) {
    uexSMS.open(num, '');
}

function mail(email) {

    uexEmail.open(email, '', '', '');
}

//延迟执行事件
function delayRun(code, time) {
    var t = setTimeout(code, time);
}

//可折叠区域 内容显示在上面
//ckbox 复选框ID； listDiv 折叠部分ID
//可参照事例Yhn/groundReport_content.html
function showDetailMSG(ckbox, listDiv) {

    try {
        $$(ckbox).checked = !$$(ckbox).checked;

        if ($$(ckbox).checked)
            $$(listDiv).className = $$(listDiv).className.replace("col-c", "");
        else
            $$(listDiv).className += ' col-c';
    }
    catch (e) {
        //alert(e);
    }
}

//创建补0函数
function p(s) {
    return s < 10 & s >= 0 ? '0' + s : s;
}

//获取文件名后缀并转为小写 e.g.:.jpg
function getFileExt(str) {
    var d = /\.[^\.]+$/.exec(str);
    return d.toString().toLowerCase();
}

//点击一浏览器方式打开
function openUrl(url) {
    var appInfo = '';
    var filter = '';
    if (uexWidgetOne.platformName == 'android') {
        appInfo = 'android.intent.action.VIEW';
        filter = 'text/html';
    }
    uexWidget.loadApp(appInfo, filter, url);
}

/*列表上划刷新 下划加载数据 Start*/
function initBounce(funcTop, funcBottom){
    uexWindow.setBounce("1");
    if (!funcTop && !funcBottom) {
        uexWindow.showBounceView("0", "rgba(255,255,255,0)", "0");
        uexWindow.showBounceView("1", "rgba(255,255,255,0)", "0");
        return;
    }
    var top = 0, btm = 1;
    uexWindow.onBounceStateChange = function(type, state){
        if (type == top && state == 2) { //顶部弹动
            funcTop();
            uexWindow.resetBounceView("0");
        }
        if (type == btm && state == 2) { //底部弹动
            funcBottom();
            uexWindow.resetBounceView("1");
        }
    }
    if (funcTop) {
        uexWindow.setBounceParams('0', '{"pullToReloadText":"下拉刷新","releaseToReloadText":"释放刷新","loadingText":"正在刷新，请稍候"}', 'donghang');
        uexWindow.showBounceView(top, "rgba(255,255,255,0)", 1);
        uexWindow.notifyBounceEvent(top, 1);
    }
    if (funcBottom) {
        uexWindow.setBounceParams('1', '{"pullToReloadText":"加载更多","releaseToReloadText":"加载更多","loadingText":"加载中，请稍候"}', 'donghang');
        uexWindow.showBounceView(btm, "rgba(255,255,255,0)", 1); //设置弹动位置及效果([1:显示内容;0:不显示])
        uexWindow.notifyBounceEvent(btm, 1); //注册接收弹动事件([0:不接收onBounceStateChange方法回调;1:接收])
    }
}


//时间格式转换{/Date(1381895400000+0800)/ 转换为----》11:50}
function data_string(str) {
    var d = eval('new ' + str.substr(1, str.length - 2));
    var ar_date = [d.getHours(), d.getMinutes()];
    for (var i = 0; i < ar_date.length; i++)
        ar_date[i] = p(ar_date[i]);
    return ar_date.join(':');
}

//取年份 2013-09-23 22:00:00
function getYear(str) {
    return str.substr(0, 4);
}
//取时分 2013-09-23 22:00:00
function getHourMin(str) {
    if (getYear(str) != "0001") {
        var index = str.indexOf(':');
		//return str.substr(index - 2, 5);
        return str.substr(index - 2, 8);//lzw截取
    }
    else
        return "";
}
function int(s) {
    return parseInt(s, 10);
}
//计算时长，如11:30 12:45，时长75
function duration(time1, time2) {
    var hour1 = int(time1.substr(0, 3));
    var min1 = int(time1.substr(3, 2));
    var hour2 = int(time2.substr(0, 2));
    var min2 = int(time2.substr(3, 2));
    return (hour2 - hour1) * 60 + (min2 - min1);
}
//计算时长，如2013-10-29 23:00:00、2013-10-30 00:02，时长1*60*60+2*60=3720(秒)
function durationSeconds(time1, time2) {
    var year1, month1, day1, hour1, minute1, second1;//second1 lzw添加2014年9月19日
    var year2, month2, day2, hour2, minute2 ,second2;//second2 lzw添加2014年9月19日
    year1 = time1.substr(0, 4);
    month1 = time1.substr(5, 2);
    day1 = time1.substr(8, 2);
    hour1 = time1.substr(11, 2);
    minute1 = time1.substr(14, 2);
	second1 = time1.substr(17, 2);//lzw添加2014年9月19日
	
	//alert(second1+"///");
	
    year2 = time2.substr(0, 4);
    month2 = time2.substr(5, 2);
    day2 = time2.substr(8, 2);
    hour2 = time2.substr(11, 2);
    minute2 = time2.substr(14, 2);
	second2 = time2.substr(17, 2);//lzw添加2014年9月19日

    var date1 = new Date(year1, month1 - 1, day1, hour1, minute1, second1);
    var date2 = new Date(year2, month2 - 1, day2, hour2, minute2, second2);
    return (date2.getTime() - date1.getTime()) / 1000;
}

//计算时长，如2013-10-29 23:00、2013-10-30 00:30，时长90(分钟）
function durationMinutes(time1, time2) {
    var s = durationSeconds(time1, time2);
    return int(s / 60);
}

//计算时长，如2013-10-29 23:00、2013-10-30 00:30，时长1h30m
function durationHM(time1, time2) {
    var s = durationSeconds(time1, time2);
    return int(s / 3600) == 0 ? (int((s % 3600) / 60) + "m") : (int(s / 3600) + "h" + int((s % 3600) / 60) + "m");
}

//时间自减1，如1h0m，变为59m
function leftTimeDecrease(leftTime) {
	logs('JS old----->'+ leftTime);
    var hours = 0, minutes = 0;
    if (leftTime.indexOf('h') != -1)
        hours = leftTime.substr(0, leftTime.indexOf('h'));
//	logs('hours----->'+ hours);
    minutes = leftTime.substr(leftTime.indexOf('h') + 1, leftTime.indexOf('m') - leftTime.indexOf('h') - 1);
//	logs("minutes------>"+ minutes);
    wholeMinutes = int(hours) * 60 + int(minutes) - 1;
    //wholeMinutes = wholeMinutes - 1 < 0 ? 0 : wholeMinutes - 1;
	logs((int(wholeMinutes / 60) == 0 ? '' : (int(wholeMinutes / 60) + "h")) + int(wholeMinutes % 60) + "m")
    return (int(wholeMinutes / 60) == 0 ? '' : (int(wholeMinutes / 60) + "h")) + int(wholeMinutes % 60) + "m";
}

//ios下解锁后，剩余时间减去锁屏时长即为现在的剩余时间
function lockLeftTimeDecrease(leftTime, pastTime) {
    var hours = 0, minutes = 0;
    if (leftTime.indexOf('h') != -1)
        hours = leftTime.substr(0, leftTime.indexOf('h'));
    minutes = leftTime.substr(leftTime.indexOf('h') + 1, leftTime.indexOf('m') - leftTime.indexOf('h') - 1);
    wholeMinutes = int(hours) * 60 + int(minutes) - int(pastTime / 60);
    return (int(wholeMinutes / 60) == 0 ? '' : (int(wholeMinutes / 60) + "h")) + int(wholeMinutes % 60) + "m";
}

function dHours(time1, time2) {
    var s = durationSeconds(time1, time2);
    return int(s / 3600);
}
function dMinutes(time1, time2) {
    var s = durationSeconds(time1, time2);
    return int((s % 3600) / 60);
}
//说明：李中稳新增函数，解决接受任务时 已开始的秒表数为0bug
function dSeconds(time1, time2) {

    var s = durationSeconds(time1, time2);
    return int((s % 60));
}
function duration2(time1, time2) {
//    alert("old time1-------->"+ time1);
//	alert("new time2-------->"+ time2);
	time1 = time1+":00";
	//alert(time1);
	var h = dHours(time1, time2);
    var m = dMinutes(time1, time2);
	var s = dSeconds(time1, time2);
	 //alert(h);
  // alert(m);
   // alert(s);
	
	if(parseInt(h)<0)h=0;
	if(parseInt(m)<0)m=0;
	if(parseInt(s)<0)s=0;
//	alert("time gogogogog-------->"+  p(h) + ":" + p(m) + ":00");
	//return p(h) + ":" + p(m) + ":00"; //以前的方案，没有计算秒
 
  //  alert(p(h) + ":" + p(m) + ":"+p(s));
	return p(h) + ":" + p(m) + ":"+p(s);//李中稳新增过后的，修改点击第二个任务后 第一个任务开始从0计时的bug
    
}

function lockDuration2(time, pastTime) {
    var hours = 0, minutes = 0, seconds = 0;
    hours = int(time.substr(0, 2));
    minutes = int(time.substr(3, 2));
    seconds = int(time.substr(6, 2));
    var newTime = hours * 3600 + minutes * 60 + seconds + int(pastTime);
    hours = int(newTime / 3600);
    minutes = int((newTime % 3600) / 60);
    seconds = int(newTime % 60);
    return p(hours) + ":" + p(minutes) + ":" + p(seconds);
}

Array.prototype.Contain = function (item) {
    var i = 0;
    for (var i; i < this.length; i++) {
        if (this[i] === item)
            return true;
    }
    return false;
};

//格式化“机位”
function formatLocation(f, t) {
    if (f == t)
        return f;
    else
        return f + '-' + t;
}
//去除数组中重复元素
function uniq(arr){
    var a = [], o = {}, i, v, len = arr.length;
    if (len < 2) {
        return arr;
    }
    for (i = 0; i < len; i++) {
        v = arr[i];
        if (o[v] !== 1) {
            a.push(v);
            o[v] = 1;
        }
    }
    return a;
}
 //年月日时分秒
function getDate(){
    var date = new Date();
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var day = date.getDate();
    var hour = date.getHours();
    var minute = date.getMinutes();
    var second = date.getSeconds();
    return year + '年' + month + '月' + day + '日 ' + hour + ':' + minute + ':' + second;
}
		
//记录界面点击量		
function recordClickCount(eventId,desKey,desValue)
{
//	uexDataAnalysis.setEvent("事件id","{'':''}");
	uexDataAnalysis.setEvent(eventId,"{'"+ desKey +"':'"+ desValue +"'}");
}	

//------------------------------------------------------------5.前台日志记录调用push方法状态 BEGIN-----------------------------------------
var fileUrl = "wgt://logs/pushText.txt";//"res://pushText.txt";
var contentTxt = "";
var fileIsCreate = false;
//创建文件
function createFile(){
    uexFileMgr.createFile(1, fileUrl);
    uexFileMgr.closeFile(1);
}

//写文本
function writeTxt(contentTxt){
//    if (fileIsCreate) {
        contentTxt = getDate() + contentTxt;
        uexFileMgr.openFile(1, fileUrl, 1);
        uexFileMgr.writeFile(1, 1, contentTxt+'\r\n');//2-1无论文件中是否已经有内容 都接着写
        uexFileMgr.closeFile(1);
//    }
}
//------------------------------------------------------------前台日志记录调用push方法状态 END-----------------------------------------	
  function getDeviceToken(){
       uexDevice.cbGetInfo = function(opId, dataType, data){
           if (dataType == 1) {
               var obj = JSON.parse(data);
               var softToken = obj.deviceToken;
               setStorage('deviceToken', softToken);
           }
       }
       uexDevice.getInfo('11');
   }
   
Array.prototype.S=String.fromCharCode(2);  
Array.prototype.in_array=function(e)  
{  
	var r=new RegExp(this.S+e+this.S);  
	return (r.test(this.S+this.join(this.S)+this.S));  
}  

//2015对比任务改变，改变的任务是否需要提示，来判断是否震动
function TaskContrast(oldT, newT) {
    for(var i=0;i<oldT.length;i++)
    {
        if(oldT[i]!=newT[i])
        {
            return true;
        }
    }
}
//任务信息对比:true：有更新，false：无更新
var oldObj;
var newObj;
function missionContrast() {
     //alert("missionContrast");
    
    if(isDefine(getStorage('Missions')) != false){
         oldObj= JSON.parse(getStorage("Missions"));   
         alert(" oldObj+: "+JSON.stringify(oldObj));
    }
   
     if(isDefine(getStorage('NewMissions')) != false)
    {
         newObj = JSON.parse(getStorage("NewMissions"));
         //alert("newObj->"+JSON.stringify(newObj));
         alert("status: "+newObj.status+" / "+isDefine(getStorage('Missions')));
        if (newObj.status == 0&&isDefine(getStorage('Missions'))) {
             //alert("key: "+oldObj);
           if (newObj.array.length>0&&oldObj.array.length>0) {
              for(var i=0;i<newObj.array.length;i++)
              {
                  alert("1");
                  var oldTasks=oldObj.array.Tasks;
                     //增
                    if (newObj.array[i].ResourceAssignmentCreatedSCO) {
                        var creatArray = newObj.array[i].ResourceAssignmentCreatedSCO;
                        for (var j = 0; j < creatArray.length; j++) {
                            var flag = true;
                            var taskId = creatArray[j].ID;
                            var assignmentId = creatArray[j].AssignmentId;
                            var taskStatus = creatArray[j].TaskStatusCode;
                            for (var o = 0; o < oldTasks.length; o++) {
                                //                                          logs('o---->'+o);
                                var oldID = oldTasks[o].ID;
                                var oldUID = oldTasks[o].AssignmentId;
                                var oldtaskStatus = oldTasks[o].TaskStatusCode;
                                if (taskId == oldID && assignmentId == oldUID && taskStatus == oldtaskStatus) {
                                    flag = false;
                                    break;
                                }
                            }
                            if (flag) {
                                return true;
                            }
                        }
                    }
                    alert("2");
                    //改--新增子任务
                    if (newObj.array[i].SubtaskAddedSCO) {
                        var upArray = newObj.array[i].SubtaskAddedSCO;
                        var addChilldIDArr = new Array();//记录已完成子任务ID
                        for(var j=0;j< upArray.length;j++)
                        {   
                            var newsId= upArray[j].ParentTaskID;//主任务ID
                            for (var o = 0; o < oldTasks.length; o++) {
                                var oldTasksId = oldTasks[o].ID;
                                if (newsId == oldTasksId) {
                                    if (!addChilldIDArr.in_array(upArray[j].ID)) {
                                         return true;
                                    }
                                }
                            }
                        }
                    }
                    
                    //改--修改子任务
                    if (newObj.array[i].SubtaskChangedSCO) {
                        var upArray = newObj.array[i].SubtaskChangedSCO;
                        var updChilldIDArr = new Array();//记录已完成子任务ID
                        for(var j=0;j< upArray.length;j++)
                        {   
                            var newsSubId=upArray[j].SubtaskId;//子任务ID
                            for (var o = 0; o < oldTasks.length; o++) {
                                var oldSubTasks=oldTasks[o].Subtasks;
                                for (var n = 0; n < oldSubTasks.length; n++) {
                                    if (newsSubId == oldSubTasks[n].ID) {
                                        if (!updChilldIDArr.in_array(upArray[j].SubtaskId)) {
                                           return true;  
                                        }
                                    }
                                }
                            }
                        }
                    }
                    
                    //改--删除子任务
                    if (newObj.array[i].SubtaskDeletedSCO) {
                        var upArray = newObj.array[i].SubtaskDeletedSCO;
                        var delChilldIDArr = new Array();//记录已完成子任务ID
                        for(var j=0;j< upArray.length;j++)
                        {
                            var newsSubId=upArray[j].SubtaskId;//主任务ID
                            for (var o = 0; o < oldTasks.length; o++) {
                                var oldSubTasks=oldTasks[o].Subtasks;
                                
                                for (var n = 0; n < oldSubTasks.length; n++) {
                                    if (newsSubId == oldSubTasks[n].ID) {
                                        if (!delChilldIDArr.in_array(newsSubId)) {
                                             return true;  
                                        }
                                    }
                                }
                            }
                        }
                    }
                    //删
                    if(newObj.array[i].ResourceAssignmentDeletedSCO)
                    {
                        var delArray = newObj.array[i].ResourceAssignmentDeletedSCO;
                        for(var j = 0; j < delArray.length; j++){
                            var delID = delArray[j].TaskId;
                            var delUID = delArray[j].AssignmentId;
                            for(var o = 0; o < oldTasks.length; o++){   
                                var oldID = oldTasks[o].ID;
                                var oldUID = oldTasks[o].AssignmentId;
                                if(oldID == delID && oldUID == delUID)
                                {
                                    return true;  
                                }
                            }
                        }
                    }
                    //改--航班详情
                //alert("航班详情"+obj.array)
                if (newObj.array[i].OperationLongDescriptionSCO) {
                    var upArray = newObj.array[i].OperationLongDescriptionSCO;
                    for (var j = 0; j < upArray.length; j++) {
                        var upTaskID = upArray[j].TaskId;
                        for (var o = 0; o < oldTasks.length; o++) {
                            var oldID = oldTasks[o].ID;
                            var delArray = "";
                            cancelIDs = getStorage("cancelIDs");
                            writeTxt(cancelIDs);
                            if(cancelIDs==undefined)
                            {
                                cancelIDs ='';
                            }
                            if (cancelIDs.length > 1 && oldTasks[o].TaskStatusCode == "CANC") {
                                if (cancelIDs.substr(cancelIDs.length - 1) == ",") {
                                    cancelIDs = cancelIDs.substr(0, cancelIDs.length - 1);
                                    delArray = cancelIDs.split(",");
                                    for (var d = 0; d < delArray.length; d++) {
                                    if (delArray[d] == upTaskID && delArray[d] ==oldID ) {
                                         return true;  
                                        }
                                    }
                                }
                            }
                            else {
                                if (oldID == upTaskID && oldTasks[o].TaskStatusCode != "COMP") {
                                    if (oldTasks[o].LongOperationDescription.Flight != upArray[j].flight.Flight) {
                                       return true;
                                    }
                                    if (oldTasks[o].LongOperationDescription.Reg != upArray[j].flight.Reg) {
                                       return true;
                                    }
                                    if (oldTasks[o].LongOperationDescription.STA != upArray[j].flight.STA) {
                                        return true;
                                    }
                                    if (oldTasks[o].LongOperationDescription.ETA != upArray[j].flight.ETA) {
                                       return true;
                                    }
                                    if (oldTasks[o].LongOperationDescription.ArrivalGate != upArray[j].flight.ArrivalGate) {
                                       return true;
                                    }
                                    if (oldTasks[o].LongOperationDescription.ArrivalPax != upArray[j].flight.ArrivalPax) {
                                        return true;
                                    }
                                    if (oldTasks[o].LongOperationDescription.CarousselNumber != upArray[j].flight.CarousselNumber) {
                                        return true;
                                    }
                                    if (oldTasks[o].LongOperationDescription.ArrivalTotalWeight != upArray[j].flight.ArrivalTotalWeight) {
                                        return true;
                                    }
                                    if (oldTasks[o].LongOperationDescription.ArrivalBagPiece != upArray[j].flight.ArrivalBagPiece) {
                                       return true;
                                    }
                                    if (oldTasks[o].LongOperationDescription.ArrivalRemarks != upArray[j].flight.ArrivalRemarks) {
                                       return true;
                                    }
                                    if (oldTasks[o].LongOperationDescription.STD != upArray[j].flight.STD) {
                                       return true;
                                    }
                                    if (oldTasks[o].LongOperationDescription.ETD != upArray[j].flight.ETD) {
                                        return true;
                                    }
                                    if (oldTasks[o].LongOperationDescription.BoardingGate != upArray[j].flight.BoardingGate) {
                                        return true;
                                    }
                                    if (oldTasks[o].LongOperationDescription.BoardingPax != upArray[j].flight.BoardingPax) {
                                       return true;
                                    }
                                    if (oldTasks[o].LongOperationDescription.DepartureTotalWeight != upArray[j].flight.DepartureTotalWeight) {
                                        return true;
                                    }
                                    if (oldTasks[o].LongOperationDescription.DepartureBagPiece != upArray[j].flight.DepartureBagPiece) {
                                       return true;
                                    }
                                    if (oldTasks[o].LongOperationDescription.DepartureRemarks != upArray[j].flight.DepartureRemarks) {
                                        return true;
                                    }
                                    if (oldTasks[o].LongOperationDescription.Stand != upArray[j].flight.Stand) {
                                       return true;
                                        //alert("jiwei")
                                    }
                                    if (oldTasks[o].LongOperationDescription.Equipment != upArray[j].flight.Equipment) {
                                      return true;
                                    }
                                    if (oldTasks[o].LongOperationDescription.OperationStatus != upArray[j].flight.OperationStatus) {
                                        return true;
                                    }
                                    if (oldTasks[o].LongOperationDescription.ArrivalMailWeight != upArray[j].flight.ArrivalMailWeight) {
                                        return true;
                                    }
                                    if (oldTasks[o].LongOperationDescription.ArrivalCargoWeight != upArray[j].flight.ArrivalCargoWeight) {
                                       return true;
                                    }
                                    if (oldTasks[o].LongOperationDescription.ArrivalBagWeight != upArray[j].flight.ArrivalBagWeight) {
                                       return true;
                                    }
                                    if (oldTasks[o].LongOperationDescription.DepartureBagWeight != upArray[j].flight.DepartureBagWeight) {
                                       return true;
                                    }
                                    if (oldTasks[o].LongOperationDescription.DepartureCargoWeight != upArray[j].flight.DepartureCargoWeight) {
                                       return true;
                                    }
                                    if (oldTasks[o].LongOperationDescription.DepartureMailWeight != upArray[j].flight.DepartureMailWeight) {
                                       return true;
                                    }
                                }
                            }
                        }
                    }
                }
                
                    //改--任务预计开始
                    if (newObj.array[i].AssignmentScheduledStartSCO) {
                        var upArray = newObj.array[i].AssignmentScheduledStartSCO;
                        for(var j=0;j< upArray.length;j++)
                        {
                            var upUID = upArray[j].AssignmentId;
                            for (var o = 0; o < oldTasks.length; o++) {
                                var oldUID = oldTasks[o].AssignmentId;
                                if (oldUID == upUID) {
                                    if (oldTasks[o].TaskStatusCode != "COMP") {
                                        return true;
                                    }
                                }
                            }
                        }
                    }
                
                    //改--任务预计结束
                    if (newObj.array[i].AssignmentScheduledEndSCO) {
                        var upArray = newObj.array[i].AssignmentScheduledEndSCO;
                        for(var j=0;j< upArray.length;j++)
                        {
                            var upUID = upArray[j].AssignmentId;
                            for (var o = 0; o < oldTasks.length; o++) {
                                var oldUID = oldTasks[o].AssignmentId;
                                if (oldUID == upUID) {
                                    if (oldTasks[o].TaskStatusCode != "COMP") {
                                         return true;
                                    }
                                }
                            }
                        }
                    }
                
                    //改--任务预计开始结束
                    if (newObj.array[i].AssignmentScheduledStartEndSCO) {
                        var upArray = newObj.array[i].AssignmentScheduledStartEndSCO;
                        for(var j=0;j< upArray.length;j++)
                        {
                            var upUID = upArray[j].AssignmentId;
                            for (var o = 0; o < oldTasks.length; o++) {
                                
                                var oldUID = oldTasks[o].AssignmentId;
                                
                                if (oldUID == upUID && oldTasks[o].TaskStatusCode != "COMP") {
                                     return true;
                                }
                            }
                        }
                    }
                    
                    //改--任务实际开始
                    if (newObj.array[i].AssignmentActualStartSCO) {
                        var upArray = newObj.array[i].AssignmentActualStartSCO;
                        for(var j=0;j< upArray.length;j++)
                        {
                            var upUID = upArray[j].AssignmentId;
                            for (var o = 0; o < oldTasks.length; o++) {
                                
                                var oldUID = oldTasks[o].AssignmentId;
                                if (oldUID == upUID && oldTasks[o].TaskStatusCode != "COMP") {
                                    
                                    if(upArray[j].ActualStart.substr(0,4) !="0001")
                                    {
                                       return true; 
                                    }
                                }
                            }
                        }
                    }
                
                   //改--任务的TaskLead
                    if (newObj.array[i].TaskLeadSCO) {
                        var upArray = newObj.array[i].TaskLeadSCO;
                        for(var j=0;j< upArray.length;j++)
                        {
                            var upUID = upArray[j].AssignmentId;
                            for (var o = 0; o < oldTasks.length; o++) {
                                
                                var oldUID = oldTasks[o].AssignmentId;
                                if (oldUID == upUID && oldTasks[o].TaskStatusCode != "COMP") {
                                    return true; 
                                }
                            }
                        }
                    }
                    //改--任务状态
                    if (newObj.array[i].TaskStatusSCO) {
                        var upArray = newObj.array[i].TaskStatusSCO;
                        for(var j=0;j< upArray.length;j++)
                        {
                            var upTaskID = upArray[j].TaskId;
                            for (var o = 0; o < oldTasks.length; o++) {
                                var oldID = oldTasks[o].ID;
                                if (oldID == upTaskID && oldTasks[o].TaskStatusCode != "COMP") {
                                    return true; 
                                }
                            }
                        }
                    }
                    //改--任务实际结束
                    if (newObj.array[i].AssignmentActualEndSCO) {
                        var upArray = newObj.array[i].AssignmentActualEndSCO;
                        for(var j=0;j< upArray.length;j++)
                        {
                            var upUID = upArray[j].AssignmentId;
                            for (var o = 0; o < oldTasks.length; o++) {
                                var oldUID = oldTasks[o].AssignmentId;
                                if (oldUID == upUID && oldTasks[o].TaskStatusCode != "COMP" && oldTasks[o].TaskStatusCode != "CANC") {
                                    return true;
                                }
                            }
                        }
                    }
                    
                    //改--进港机位号
                    if (newObj.array[i].TaskStartLocationSCO) {
                        var upArray = newObj.array[i].TaskStartLocationSCO;
                        for(var j=0;j< upArray.length;j++)
                        {
                            var upTaskID = upArray[j].TaskId;
                            for (var o = 0; o < oldTasks.length; o++) {
                                var oldID = oldTasks[o].ID;
                                if (oldID == upTaskID && oldTasks[o].TaskStatusCode != "COMP") {
                                     return true;
                                }
                            }
                        }
                    }
                    
                    //改--出港机位号
                    if (newObj.array[i].TaskEndLocationSCO) {
                        var upArray = newObj.array[i].TaskEndLocationSCO;
                        for(var j=0;j< upArray.length;j++)
                        {
                            var upTaskID = upArray[j].TaskId;
                            for (var o = 0; o < oldTasks.length; o++) {
                                
                                var oldID = oldTasks[o].ID;
                                if (oldID == upTaskID && oldTasks[o].TaskStatusCode != "COMP") {
                                     return true;
                                }
                            }
                        }
                    }
                    
                    //改--进出港机位号
                    if (newObj.array[i].TaskLocationSCO) {
                        var upArray = newObj.array[i].TaskLocationSCO;
                        for(var j=0;j< upArray.length;j++)
                        {
                            var upTaskID = upArray[j].TaskId;
                            for (var o = 0; o < oldTasks.length; o++) {
                                
                                var oldID = oldTasks[o].ID;
                                if (oldID == upTaskID && oldTasks[o].TaskStatusCode != "COMP") {
                                    return true;
                                }
                            }
                        }
                    }
                    
                    //改--航班状态
                    if (newObj.array[i].TaskOperationStatusSCO) {
                        var upArray = newObj.array[i].TaskOperationStatusSCO;
                        for(var j=0;j< upArray.length;j++)
                        {
                            var upTaskID = upArray[j].TaskId;
                            for (var o = 0; o < oldTasks.length; o++) {
                                
                                var oldID = oldTasks[o].ID;
                                if (oldID == upTaskID && oldTasks[o].TaskStatusCode != "COMP") {
                                    return true;
                                }
                            }
                        }
                    }
                    //改--任务机号
                    if (newObj.array[i].TaskInternalNameSCO) {
                        var upArray = newObj.array[i].TaskInternalNameSCO;
                        for(var j=0;j< upArray.length;j++)
                        {
                            var upTaskID = upArray[j].TaskId;
                            for (var o = 0; o < oldTasks.length; o++) {
                                
                                var oldID = oldTasks[o].ID;
                                if (oldID == upTaskID && oldTasks[o].TaskStatusCode != "COMP") {
                                    return true;
                                }
                            }
                        }
                    }
                    
                    //改--出港航班号
                    if (newObj.array[i].TaskExternalNameSCO) {
                        var upArray = newObj.array[i].TaskExternalNameSCO;
                        for(var j=0;j< upArray.length;j++)
                        {
                            var upTaskID = upArray[j].TaskId;
                            for (var o = 0; o < oldTasks.length; o++) {
                                var oldID = oldTasks[o].ID;
                                if (oldID == upTaskID && oldTasks[o].TaskStatusCode != "COMP") {
                                    return true;
                                }
                            }
                        }
                    }
                    //改--航班显示名称
                    if (newObj.array[i].TaskDisplayNameSCO) {
                        var upArray = newObj.array[i].TaskDisplayNameSCO;
                        for(var j=0;j< upArray.length;j++)
                        {
                            var upTaskID = upArray[j].TaskId;
                            for (var o = 0; o < oldTasks.length; o++) {
                                var oldID = oldTasks[o].ID;
                                if (oldID == upTaskID && oldTasks[o].TaskStatusCode != "COMP") {
                                    return true;
                                }
                            }
                        }
                    }
              }
          }
        }
         setStorage("Missions",JSON.stringify(newObj));  //最新消息保存为对照旧消息
         return false;
    }
      return false;
}
//地服小组成员引用地址
//var h_yddfUrl="http://172.31.64.34:8011/sdk10098/public/";//测试地址 
//var h_yddfUrl="http://mumobiletest30.ceair.com/mas/sdk10370/public/";//mas 地址
var h_yddfUrl="http://store.ceair.com/mas/sdk10098/public/";//生产 地址